package com.hp.controller;

import com.hp.pojo.House;
import com.hp.service.HouseService;
import com.hp.service.RentingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController

public class HouseController {
    @Autowired private HouseService houseService;

    @PostMapping("/addHouse")
    Map<String, Object> addHouse(House house){
        /*
        增加一条房信息
         */
        return houseService.addHouse(house);
    }
    @PostMapping("/getAllHouses")
    Map<String,Object> getAllHouses (){
        /*
        查找所有房信息
         */
        return houseService.getAllHouses();
    }

    @PostMapping("/getHousesByUserId")
    Map<String,Object> getHousesByUserId (int userId){
        /*
        通过用户id找其房消息
         */
        return houseService.getHousesByUserId(userId);
    }


    @PostMapping("/deleteHouseById")
    Map<String,String> deleteHouseById (int houseId){
        /*
        通过用户id删除房源信息
         */
        return houseService.deleteHouseById(houseId);
    }

    @PostMapping("/getAllHousesByAddress")
    Map<String,Object> getAllHousesByAddress (String address){
        /*
        通过房源详细地址 查找房信息
         */
        return houseService.getAllHousesByAddress(address);
    }
    @PostMapping("/getRecommendOnHead")
    Map<String,Object> getRecommendOnHead (){
        /*
        获取推荐的四个
         */
        return houseService.getRecommendOnHead();
    }
    //改还甚么都没写
    @PostMapping("/getHouseById")
    Map<String,Object> getHouseById (int houseId){
        return houseService.getHouseById(houseId);
    }


    @PostMapping("/getHouseBySearch")
    Map<String,Object> getHouseBySearch(String searchValue){
        return houseService.getHouseBySearch(searchValue,false);
    }

    @PostMapping("/AddVrLinkToHouse")
    Map<String,Object> AddVrLinkToHouse(int houseId,String vrLink){
        return houseService.AddVrLinkToHouse(houseId,vrLink);
    }

    @PostMapping("/getHousesByMap")
    Map<String,Object> getHousesByMap(String address){
        return houseService.getHousesByMap(address);
    }

}
